﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;

namespace PhoneMap.ViewModel
{
    public class DataParser
    {
        public static async Task<T> DoGetJonAsync<T>(string data)
        {
            try
            {
                var ser = new DataContractJsonSerializer(typeof(T));
                var ms = new MemoryStream(Encoding.Unicode.GetBytes(data));
                return await Task.Run(() => (T)ser.ReadObject(ms));
            }
            catch (Exception ex)
            {
                throw new Exception("Exception calling GetGenericRequestAndDeserialize", ex);
            }

        }

    }
}
